package com.zzl.study.auth.enums;

import com.zzl.study.auth.domain.dto.Options;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

/**
 * @author: zhangzl
 * @date: 2023/12/7 20:26
 * @version: 1.0
 * @description: 客户端认证方法枚举
 * @see org.springframework.security.oauth2.core.ClientAuthenticationMethod
 */
@Getter
public enum ClientAuthenticationMethod {

    /**
     * BASIC认证，HTTP基本认证，将客户端ID和密钥设置在请求头中
     */
    CLIENT_SECRET_BASIC("BASIC", "client_secret_basic"),

    /**
     * POST认证，HTTP的POST请求认证，将客户端ID和密钥设置在请求参数中
     */
    CLIENT_SECRET_POST("POST", "client_secret_post");

    /**
     * 描述
     */
    private final String name;

    /**
     * 值
     */
    private final String value;


    ClientAuthenticationMethod(String name, String value) {
        this.name = name;
        this.value = value;
    }

    /**
     * 客户端认证方法枚举转下拉框选项集合
     *
     * @return 下拉框选项集合
     */
    public static List<Options> toList() {
        return Arrays.stream(ClientAuthenticationMethod.values()).map(e -> new Options(e.getName(), e.getValue())).toList();
    }

}
